package dynamizer;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.StringTokenizer;

public class StringTools {
	public String fileToString(File initialFile) {
		String string = "";
		Scanner scanner;
		try {
			scanner = new Scanner(initialFile);
			while (scanner.hasNextLine()) {
				string += scanner.nextLine() + "\n";
			}
			scanner.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
		return string;
	}

	public ArrayList<String> parseStringWithSeparatorToStringArray(
			String string, String separator) {

		ArrayList<String> elements = new ArrayList<String>();

		StringTokenizer st = new StringTokenizer(string, separator);
		while (st.hasMoreTokens()) {
			elements.add(st.nextToken());
		}
		return elements;
	}
}
